package cn.tedu.controller;

import cn.tedu.pojo.Chapter;
import cn.tedu.service.ChapterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ChapterController {
    @Autowired
    private ChapterService chapterService;
    //查看所有章节
    @GetMapping("/getChapterByNovelId")
    public List<Chapter> findChapter(@RequestParam("novelId") Integer novelId){
        List<Chapter> chapters = chapterService.getChapterByNovelId(novelId);
        return chapters;
    }
    //查看章节内容
    @GetMapping("/getContentByChapterId")
    public String getContent(@RequestParam("chapterId") Integer chapterId){
        String content = chapterService.getContentByChapterId(chapterId);
        return content;
    }
}
